{include file="public/header"}
<body>
<style>
	.ppp_title{
		color: #fff;
	}
</style>
<div class="sectionY sectionY_tttt">
	<a href="{:url('Paytype/safecenter')}">
		<img src="__PUBLIC__/home/images/v10_a9.png" alt="" class="a1" >
	</a>
		<p class="p1">
			<span class="ppp_title">交易密码</span>
		</p>
	</div>
	<div class="kong1"></div>
<div class="bg_fixed_v10_1"></div>
	<div class="res_section1">
			<div class="all_1">
				<div class="f1 f2" style="padding-bottom: 20px">
					<span class="s1 ">手机号码：</span>
					<span class="snum" style="color: #fff">{$userinfo.selfphone}</span>
					<span class="s2 s3 sxf" id="getVcode" style="top: 5px;height: 35px;line-height: 35px">获取验证码</span>
				</div>
				<div class="f1">
					<span class="s1 ">验证码：</span>
					<input type="text" class="input1" placeholder="请输入短信验证码" name='codes' />

				</div>
				<div class="f1">
					<span class="s1 ">新密码：</span>
					<input type="passw" name='pwd' class="input1" placeholder="请输入新的密码">
				</div>
				<div class="f1">
					<span class="s1 ">确定新密码：</span>
					<input type="passw" name='newpwd' class="input1" placeholder="请再次输入新的密码">
				</div>
				<div class="sub" style="margin-top: 50px">
					<input type="submit" value="提交修改">
				</div>
			</div>
	</div>
</body>
</html>
<script>
    var is_enable=true;
	$(function(){
        /*获取验证码*/
        $(".s3").click(function(){
            var times = 60;
            /*手机号格式正确，发送验证码并倒计时开始*/
            $.ajax({
                type: 'POST',
                url: "{:url('Paytype/sendsms')}",
                dataType: "html",
                data: "tel=1",
                success:function(msg){
                    msg= JSON.parse(msg);
                    if(msg.result_code==0){
                        layer.alert(msg.result_info,{icon: 1,shade:0.8,title:"成功提示:"});
                        is_enable = false;
                        $("#getVcode").html(times+"秒后发送");
                        var index = setInterval(function () {
                            if(times == 0){
                                clearInterval(index);
                                is_enable = true;
                                $("#getVcode").html("发送验证码");
                            }else{
                                times--;
                                $("#getVcode").html(times+"秒后发送");
                            }
                        }, 1000);
                    }else {
                        layer.alert(msg.result_info,{icon: 2,shade:0.8,title:"错误提示:"});
                    }
                },
                error:function(){
                    layer.alert('系统繁忙，请稍后再试！',{icon: 2,shade:0.8,title:"错误提示:"});
                }
            });
        });

		/*重置密码*/
		$("input[type=submit]").click(function(){
			var codes	= $('input[name=codes]').val();
			var pwds	= $('input[name=pwd]').val();
			var newpwd	= $('input[name=newpwd]').val();
			if(codes==''){
				layer.alert('请输入验证码！',{icon: 2,shade:0.8,title:"错误提示:"});return false;
			}
			if(pwds==''){
				layer.alert('请输入新密码!',{icon: 2,shade:0.8,title:"错误提示:"});return false;
			}
			if(pwds!=newpwd){
				layer.alert('两次输入的密码不一致！',{icon: 2,shade:0.8,title:"错误提示:"});return false;
			}

			$.ajax({
				type: 'POST',
				url: "{:url('Paytype/chagnesign')}",
				dataType: "html",
				data: "tel=1&codes="+codes+"&pwds="+pwds,
				success:function(msg){
                    msg= JSON.parse(msg);
                    if(msg.result_code==0){
                        layer.msg('修改成功！',{icon: 1,shade:0.8,time: 2000,end:function(){
                                window.location.href="{:url('Paytype/safecenter')}";
                            }});
                        return false;
                    }else{
                        layer.alert(msg.result_info,{icon: 2,shade:0.8,title:"错误提示:"});
                    }
				},
				error:function(){
					layer.alert('系统繁忙，请稍后再试！',{icon: 2,shade:0.8,title:"错误提示:"});
				}
			});
		});
	})
</script>
